const KoaRouter = require('@koa/router')
const fileRouter = new KoaRouter({ prefix: '/file' })

const { verifyAuthorization } = require('../middleware/login.middleware')
const {
	handleAvatar,
	handlePostPicture,
	handleEventPicture
} = require('../middleware/file.middleware')
const fileController = require('../controller/file.controller')

// 上传头像的接口
fileRouter.post(
	'/avatar',
	verifyAuthorization,
	handleAvatar,
	fileController.uploadAvatar
)

// 上传帖子图片
fileRouter.post(
	'/post/picture',
	verifyAuthorization,
	handlePostPicture,
	fileController.uploadPostPicture
)

// 上传活动图片
fileRouter.post(
	'/event/picture',
	verifyAuthorization,
	handleEventPicture,
	fileController.uploadEventPicture
)

module.exports = fileRouter
